import router from '@/router/index.js'

class PageServer {
  constructor() {
    this.pageMap = new Map()
  }
  init(routes) {
    routes.forEach(t => {
      if ('/' === t.path) return
      let e = {
        name: t.name,
        path: t.path,
        tlConfig: t.component.timeline,
        parts: t.component.pageConfig,
        reverseTimeScale: t.component.reverseTimeScale || 3
      }
      this.pageMap.set(t.path, e)
    })
  }
  getPageByPath(path) {
    return this.pageMap.get(path)
  }
}

const pageServer = new PageServer()
pageServer.init(router.options.routes)

export default pageServer
